// HJ41.[set] 称砝码
// https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c    [中]
// n种砝码，多少种重量 set
//现有n种砝码，重量互不相等，分别为 m1,m2,m3…mn,每种砝码对应的数量为
// x1,x2,x3...xn
//现在要用这些砝码去称物体的重量(放在同一侧)，问能称出多少种不同的重量。
//称重重量包括 0
//输入 2
// 1 2
// 2 1
//输出 5
//可以表示出0，1，2，3，4五种重量。

#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef pair<int, int> Scale;  // weight,count

// W0 x X0 + W1 X X1 + W2 X X2 + ... + Wn X Xn = Sum
// map<Sum, kCount>   plist
// 5 X 4

//#define DEBUG_

#ifdef DEBUG_
#define FP(...) printf(__VA_ARGS__)
#else
#define FP(...)
#endif

int getWeightCount(const vector<Scale>& vtScale) {
  set<int> stWeight;
  for (auto [weight, count] : vtScale) {
    set<int> stTmp(stWeight);
    for (int i = 0; i <= count; i++) {
      int nSum = weight * i;
      stWeight.insert(nSum);
      for (auto nAdd : stTmp) {
        stWeight.insert(nSum + nAdd);
      }
    }
  }
  for (auto it : stWeight) FP("%d,", it);
  FP("\n");
  return stWeight.size();
}

int main() {
  int num;
  cin >> num;
  int tmp;
  vector<Scale> vtScale(num);
  for (int i = 0; i < num; i++) {
    cin >> vtScale[i].first;
  }
  for (int i = 0; i < num; i++) {
    cin >> vtScale[i].second;
  }
  for (auto it : vtScale) {
    FP("%d,%d\n", it.first, it.second);
  }
  FP("\n");
  int nKind = getWeightCount(vtScale);
  printf("%d\n", nKind);

  return 0;
}
